<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
     <%@ page import="java.util.Calendar"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Discussion Board</title>
<meta name="keywords" content="free css website template, gift red, christmas, 3-column layout, CSS, HTML" />
<meta name="description" content="Gift Red is free website template by templatemo.com" />
<link href="templatemo_style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">
<script type="text/javascript" src="//code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript" src="//code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script>

<script type='text/javascript' src='js/logging.js'></script>
<script type="text/javascript">
	$(function() {
		$("#register").click(function(){
			location.href="registerView.do";
		});
		
		
		$("#login").click(function(){
			if($("#id").val().length==0){
				alert("아이디를 입력하세요!");
				return;
			}else if($("#password").val().length==0){
				alert("비밀번호를 입력하세요!");
				return;
			}
			$("#loginForm").submit();
		}); 
		
		$("#logoutBtn").click(function(){
			location.href="logout.do";
		});
		
		$("#myPage").click(function(){
			location.href="myPage.do?id=${sessionScope.mvo.id}";
		});
		
		///////////////////////////////////////////////////
		
		<%-- 글수정 버튼 --%>
		$("#modifyBtn").click(function() {
			location.href="${initParam.root}/board_goUpdateFileBoard.do?fileNo=${requestScope.fvo.fileNo}";
		});
		
		<%-- 글삭제 버튼 --%>	
		$("#deleteBtn").click(function() {
			location.href="${initParam.root}/board_erasureFileBoard.do?fileNo=${requestScope.fvo.fileNo}&fileName=${requestScope.fvo.fileName}";
		});
	});
	
	function downloadFile(filename){
		alert(filename);
		if(confirm(filename+" 다운로드하시겠습니까?")){
			location.href="${initParam.root}/board_fileDownload.do?filename="+filename;
		} else {
			return false;
		}
	}
</script>
<link href="${initParam.root}/css/style.css" rel="stylesheet" />
</head>
<body>

<div id="templatemo_wrapper">
	
    <!-- <div id="templatemo_header"> -->
    	<div id="site_title"><h1></h1></div>
    	
        <div id="templatemo_menu">
         
            <ul>
              <li><a href="home.do" class="current home">Home</a></li>
              <li><a href="myPage.do">MyPage</a></li>
              <li><a href="ttboard.do">Tech & Tip</a></li>
              <li><a href="news.do">News</a></li>
              <li><a href="qnA.do">QnA</a></li>
              <li ><a href="discussion.do">Discussion</a></li>
              <li ><a href="download.do">Download</a></li>
            </ul>
        </div> <!-- end of templatemo_menu -->   
        
    <!-- </div> end of header -->
    <br><br>
    <div id="templatemo_left_sidebar">
    	<div class="sb_box">
          <div class="content_title"><span></span>Java Box!</div>
				<c:choose>
				<c:when test="${sessionScope.mvo==null }">
				<form action="login.do" method="post" id="loginForm">
				 <input type="text" id="id" name="id" placeholder="ID"><br>
				 <input type="password" id="password" name="password" placeholder="PassWord"><br>
				<input type="button" id="register" value="회원가입">
				<input type="button" id="login" value="로그인"><br><br>
				</form>
				</c:when>
				<c:otherwise>
				ID : ${sessionScope.mvo.id}<br>
				Name : ${sessionScope.mvo.name}<br>
				Point : ${sessionScope.mvo.point}<br>
				Grade : ${sessionScope.mvo.grade}<br>
				<input type="button" value="로그아웃" id="logoutBtn">
				<input type="button" value="마이페이지" id="myPage">
				</c:otherwise>
				</c:choose>
            <ul class="tmo_list">
                <li><a href="#">Praesent pretium ligula</a></li>
                <li><a href="#">Fusce at massa mollis</a></li>
            </ul>
		</div>        
        <a href="#" class="sb_ads"><img src="images/templatemo_ad_1.jpg" alt="image 1" /></a>
        <a href="#" class="sb_ads"><img src="images/templatemo_ad_2.jpg" alt="image 2" /></a>
    
    </div> <!-- end of left sidebar -->
<!-- start of view page -->
     
<center>
<h2>자료실</h2>
	<table rules="all">
		<tr>
			<td>No ${requestScope.fvo.fileNo }</td><td colspan="2">${requestScope.fvo.fileTitle }</td>
		</tr>
		<tr>
			<td>Writer ${requestScope.fvo.fileWriter }</td><td>Date ${requestScope.fvo.fileDate }</td><td>Count ${requestScope.fvo.fileCount }</td>
		</tr>
		<tr>
			<td colspan="3"><textarea id="fileContent" rows="10" cols="60" style="resize:none" readonly="readonly">${requestScope.fvo.fileContent }</textarea></td>
		</tr>
		<tr><td colspan="3">
		<c:choose>
			<c:when test="${requestScope.fvo.fileName != null }">
				<a href="javascript:downloadFile('${requestScope.fvo.fileName }')">${requestScope.fvo.fileName }</a>
			</c:when>
			<c:otherwise>
				해당 글엔 업로드된 파일이 없습니다!!
			</c:otherwise>
		</c:choose>
		</td></tr>
	</table><br><br>
	<c:if test="${sessionScope.mvo.id==requestScope.fvo.fileWriter }">
		<input type="button" value="수정" id="modifyBtn">
		<input type="button" value="삭제" id="deleteBtn">
	</c:if>
</center>
 
<!-- end of view page -->
<div id="templatemo_footer_wrapper">
    <div id="templatemo_footer">
        Copyright © 2072 <a href="#">Your Company Name</a> | <a rel="nofollow" href="http://www.templatemo.com/preview/templatemo_362_gift_red">Gift Red</a> by <a href="http://www.templatemo.com" rel="nofollow" target="_parent" title="free css templates">templatemo</a>
        <div class="cleaner"></div>
    </div>
</div>
</div>

</body>
</html>